<!--只用于迁坟-->
<template>
    <div class='funeral_item_table'>
        <table-edit-group ref="tableeditgroup" :dataField="dataField"   :listField="listField"  :data="data"   @input="changeInput" isGroup="Y" groupKey="szi_ex8" groupAmt="szi_ex2" groupNum="szi_ex4" groupTotalAmt="szi_ex5" total="szi_ex12" isDel="N"></table-edit-group>
        <div  class='amt_total' >
            <!--div style='float:left;line-height:40px;'>减免类型：</div>
            <el-select v-model="value" placeholder="请选择" style='width:120px;float:left;'>
                <el-option
                v-for="item in options"
                :key="item.value"
                :label="item.label"
                :value="item.value">
                </el-option>
            </el-select-->
            <div class='amt_total_item'>
                <span>总金额:&nbsp;&nbsp;</span><span v-text="amt_totals" style='color:green;font-weight:bold;margin-right:30px'></span>
                <span v-if="jm_totals">减免金额:&nbsp;&nbsp;</span><span v-text="jm_totals" v-if="jm_totals" style='color:red;font-weight:bold;margin-right:30px'></span>
                <span v-if="yh_totals">优惠金额:&nbsp;&nbsp;</span><span v-text="yh_totals" v-if="yh_totals" style='color:red;font-weight:bold;margin-right:30px'></span>
                <span>实收金额:&nbsp;&nbsp;</span><span v-text="sh_totals" style='font-weight:bold;margin-right:30px'></span>
            </div>
            
        </div>
        <!--el-tooltip content="点击选择服务项目" placement="top" >
            <el-button type="success" icon="el-icon-goods" circle style='position:absolute;bottom:50px;right:50px' @click="drawer=true" ></el-button>
        </el-tooltip-->
        <el-drawer
            title="服务项目选择"
            :visible.sync="drawer"
            :direction="direction"
            append-to-body>
            <div class="left_menu">
                <funeral-item-select-show :appid="appid" @addItem="addItem" @changeAmt="changeAmts" @removeItem="removeItem" :data="data" :dataField="dataField" ></funeral-item-select-show>
            </div>
        </el-drawer>
    </div>
</template>
<script>
import tableEditGroup  from '../edit/tableEditGroup.vue'
import FuneralItemSelectShow  from '../byg/FuneralItemSelectShow.vue'
export default {
    props:['dataField','listField','data','params','appid','isgm'],
    name:'batch-funeral-item-table',
    components: {
       tableEditGroup,
       FuneralItemSelectShow
    },
    data(){
        return{
            showtable:false,
            amt_totals:'',
            sh_totals:'',
            jm_totals:'',
            yh_totals:"",
            sfItemData:[],
            hy_ex6:'',
            options: [],
            jmJson:[],
            value: '',
            drawer: false,
            direction: 'rtl',
            change:false,
            isJm:false,
            sz_ex42:"",
            isSetGlf:"N",
            gm_dat3:"",
            gm_dat4:"",
            c_ex4:""
        }
    },
    created(){
       /* if(this.dataField){
             this.showtable=true;
            this.tableData=this.data[this.dataField];
        }*/
        
        this.loadJm();
       
        this.$parent.$el.getElementsByClassName("el-card__body")[0].style.paddingBottom="0";
        
    },
    mounted(){
        this.changeAmt();
        
    
    },
    methods:{
        setJm(){
            this.isJm=true;
            //减免
            if(this.value){
                let jmJson={};
                for(let i=0;i<this.jmJson.length;i++){
                    //this.value就是选择的减免类型
                    if(this.jmJson[i].name==this.value){
                        jmJson=this.jmJson[i];
                    }
                    let jmJson_=this.jmJson[i];
                    if(jmJson_.item){
                        for(let j=0;j<jmJson_.item.length;j++){
                            let szi_ex5_=Number(jmJson_.item[j].szi_ex5);
                            let szi_ex18=jmJson_.item[j].szi_ex18;
                            
                            if(szi_ex5_>0){
                                let index=-1;
                                while(index!=-2){
                                    for(let i=0;i<this.data[this.dataField].length;i++){
                                        let datas=this.data[this.dataField][i];
                                        let szi_ex18_=datas.szi_ex18;
                                        if(szi_ex18_==szi_ex18)
                                            index=i;
                                    }
                                    if(index!=-1){
                                        this.$delete(this.data[this.dataField],index);
                                        
                                        index=-1;
                                    }else{
                                        index=-2;
                                    }
                                    
                                }
                                
                            
                                
                            }
                        }
                    }
                    
                    
                }
                //减免的json
                if(jmJson&&jmJson.item){
                    
                    let items=[];
                    let dels=[]
                    //把这个减免套餐必填项目带入
                    for(let j=0;j<jmJson.item.length;j++){
                        let szi_ex1=jmJson.item[j].szi_ex1;
                        let szi_ex5_=Number(jmJson.item[j].szi_ex5);
                        let szi_ex18=jmJson.item[j].szi_ex18;
                        //这个会判断金额大于0，是因为在减免类型的子表中有些实际不是减免项目，是需要根据选择的减免类型必选项目
                        if(szi_ex5_>0){
                            let index=-1;
                            while(index!=-2){
                                for(let i=0;i<this.data[this.dataField].length;i++){
                                    let datas=this.data[this.dataField][i];
                                    let szi_ex18_=datas.szi_ex18;
                                    if(szi_ex18_==szi_ex18)
                                        index=i;
                                }
                                if(index!=-1){
                                    this.$delete(this.data[this.dataField],index);
                                    
                                    dels.push(index);
                                    index=-1;
                                }else{
                                    index=-2;
                                }
                                
                            }
                            
                           
                            items.push(jmJson.item[j]);
                            
                        }
                        
                    }
                   
                    let len=this.data[this.dataField].length;
                    console.log("len==="+len);
                    console.log(JSON.stringify(this.data[this.dataField]))
                    for(let i=0;i<items.length;i++){
                        this.$set(this.data[this.dataField],len,items[i]);  
                        len++;
                    }
                    let itemss=[];
                    for(let i=0;i<this.data[this.dataField].length;i++){
                        let szi_ex8=this.data[this.dataField][i].szi_ex8;
                        let szi_ex2=Number(this.data[this.dataField][i].szi_ex2);
                        let szi_ex4=Number(this.data[this.dataField][i].szi_ex4);
                        let szi_ex5=Number(this.data[this.dataField][i].szi_ex5);
                        let szi_ex18=this.data[this.dataField][i].szi_ex18;
                        let sf_ex41=this.data[this.dataField][i].sf_ex41;
                        let isOk=false;
                        let item={};
                        let isCover=false;
                        this.change=true;
                        //console.log("szi_ex1====="+this.data[this.dataField][i].szi_ex1+"=="+szi_ex18)
                        for(let j=0;j<jmJson.item.length;j++){
                            let szi_ex1=jmJson.item[j].szi_ex1;
                            let szi_ex5_=Number(jmJson.item[j].szi_ex5);
                            //console.log("szi_ex11==="+szi_ex1);
                            if(szi_ex1==szi_ex18){
                               // console.log("szi_ex1=="+szi_ex1+"="+szi_ex5_+"="+szi_ex5);
                                isOk=true;
                                item=jmJson.item[j];
                                if(sf_ex41&&sf_ex41!=undefined){
                                    sf_ex41=Number(sf_ex41);//这个就是最多的减免金额，在收费项目里输入减免金额则不能大于他
                                    if(sf_ex41>-szi_ex5&&sf_ex41<0){
                                        item.szi_ex4="1";
                                        item.szi_ex2=sf_ex41;
                                        item.szi_ex5=sf_ex41;
                                    }else{
                                        
                                        item.szi_ex2=-szi_ex2;
                                        item.szi_ex4=szi_ex4;
                                        item.szi_ex5=-szi_ex5;
                                    }
                                }else{
                                    if(szi_ex5_>-szi_ex5&&szi_ex5_<0){
                                        item.szi_ex4="1";
                                        item.szi_ex2=szi_ex5_;
                                        item.szi_ex5=szi_ex5_;
                                    }else{
                                        
                                        item.szi_ex2=-szi_ex2;
                                        item.szi_ex4=szi_ex4;
                                        item.szi_ex5=-szi_ex5;
                                    }
                                }
                                
                                if(!item.szi_ex13)
                                    item.szi_ex13=this.params;
                                //this.$refs.tableEditss.removeItemByName(item.szi_ex1);   
                                
                               
                            }

                        }
                        let index=-1;
                        let item_={}
                        for(let i=0;i<this.data[this.dataField].length;i++){
                            
                            let szi_ex1=this.data[this.dataField][i].szi_ex1;
                            if(szi_ex1==szi_ex18){
                                isCover=true;
                                index=i;
                                item_=this.data[this.dataField][i];
                            }
                                

                        }
                        if(isOk&&isCover){
                             if(item_.szi_ex2!=item.szi_ex2||item_.szi_ex4!=item.szi_ex4||item_.szi_ex5!=item.szi_ex5){
                                    /*this.$refs.tableEditss.setData(index,'szi_ex5',item.szi_ex5); 
                                    this.$refs.tableEditss.setData(index,'szi_ex2',item.szi_ex2); 
                                    this.$refs.tableEditss.setData(index,'szi_ex4',item.szi_ex4); */
                                 this.$set(this.data[this.dataField],index,item);   
                             }
                            
                        }else if(isOk)
                            //this.$refs.tableEditss.addItem(JSON.stringify(item));
                            itemss.push(item);

                    }
                    for(let i=0;i<itemss.length;i++){
                        this.$set(this.data[this.dataField],this.data[this.dataField].length,itemss[i])
                    }

                    


                }
            }else{//去掉减免
                let isOk=true;
                while(isOk){
                    let jmIndex=-1;
                    let isOk2=false;
                    for(let i=0;i<this.data[this.dataField].length;i++){
                        let szi_ex7=this.data[this.dataField][i].szi_ex7;
                        if(szi_ex7=="减免"){
                            jmIndex=i;
                            isOk2=true;
                            break;
                        }
                    }
                    this.$delete(this.data[this.dataField],jmIndex);
                    if(!isOk2){
                        isOk=false;
                    }
                }
                 
            }
             this.isJm=false;
        },
        loadJm(){
            this.$post(this.appid,"byg/funeral/getFuneralSfItemJm",{}).then(data=>{
                this.jmJson=data;
                this.options=[];
                let option_={};
                option_.label="请选择";
                option_.value="";
                this.options.push(option_)
                for(let i=0;i<this.jmJson.length;i++){
                    let option={};
                    option.label=this.jmJson[i].name;
                    option.value=this.jmJson[i].name;
                    this.options.push(option);
                }
            });
        },
        removeItem(data){
            console.log("11111111111111111111111111111111111111111111111111111");
            console.log(data);
            let item=JSON.parse(data);
            let id=item.id;
            let num=item.num;

            let isDelete=false;
            let index=-1;
            for(let i=0;i<this.data[this.dataField].length;i++){
                console.log("szi_ex8=="+this.data[this.dataField][i].szi_ex8+"="+id+"="+this.data[this.dataField][i].szi_ex1)
                if(this.data[this.dataField][i].szi_ex8==id){
                    console.log("找到了..........................")
                    if(num>0){
                         let datas=this.data[this.dataField][i];
                        let szi_ex2=datas.szi_ex2;
                        let szi_ex5=num*szi_ex2;
                        datas.szi_ex4=num;
                        datas.szi_ex5=szi_ex5;
                        
                        this.$set(this.data[this.dataField],i,datas);
                    }else{
                       index=i;
                       isDelete=true;
                    }
                   
                }
            }
            if(isDelete){
                 this.$delete(this.data[this.dataField],index);
            }
        },
        //添加服务项目的主方法
        addItem(data){
            console.log("addItem===========================ss==============");
            console.log(data)
            let datas=JSON.parse(data);
            
            if(datas.addType=="string"){
                let itemType=datas.itemType;
                let name=datas.val;
                
                if(this.sfItemData.length==0){
                    this.$post(this.appid,"byg/funeral/getFuneralSfItem",{}).then(data=>{
                        this.sfItemData=[];
                        for(let i=0;i<data.item.length;i++){
                            this.sfItemData.push(data.item[i]);
                        }
                        
                        this.addItemDetail(name,itemType,datas.hour,datas.day);
                    
                    })
                }else{
                    this.addItemDetail(name,itemType,datas.hour,datas.day);
                }
                
            }else{
                if(!datas.szi_ex13)
                    datas.szi_ex13=this.params;
                let isOk=true;
                //相同的项目增加数量
                for(let i=0;i<this.data[this.dataField].length;i++){
                    let szi_ex8=this.data[this.dataField][i].szi_ex8;
                    let szi_ex4=this.data[this.dataField][i].szi_ex4;
                    let szi_ex2=this.data[this.dataField][i].szi_ex2;
                    if(szi_ex8==datas.szi_ex8){
                         szi_ex4++;
                         let data_=this.data[this.dataField][i];
                         data_.szi_ex4=szi_ex4;
                         data_.szi_ex5=szi_ex2*szi_ex4;
                         this.$set(this.data[this.dataField], i , data_); 
                         isOk=false;
                    }
                }
                if(isOk){
                    this.$set(this.data[this.dataField], this.data[this.dataField].length , datas);
                    this.addRelItem(datas,datas.hour,datas.day); 
                }
             
            }
            
            
        },
        changeAmts(){
            this.changeAmt();
        },
        addRelItem(row,hour,day){//添加相搭配项目，并且有些搭配项目是要根据添加或者小时计算数量的，也要更新这些相关联项目的数量
            let sf_id=row.szi_ex8;
            //添加搭配项目
            this.$post(this.appid,"/byg/funeral/getSfItemDp",{sf_id:sf_id}).then(data=>{
              
                
                let szi_ex1_=row.szi_ex1;

                //反向，这个主要是用于添加相搭配项目的时候，找到主项目，并且获取主项目的数量和金额赋值
                //因为这个方法在添加主项目和相关联项目时都会调用
                //比如主服务项目（礼厅）先添加完成，然后找到礼厅相关联的项目szi_ex19,因为礼厅是主项目所有这个字段为空，下面for获取不到row_,就不存在要该礼厅的数量和金额
                //但主项目（礼厅）添加完后，会从后台获取到data.name（在下面）然后添加子项目（冰柜）。子项目添加完成后，又进入该方法，冰柜的szi_ex19值就是相对应的礼厅名称
                //然后就可以反向获取上一步添加好的礼厅的数量，然后冰柜根据获取的数量重新计算金额，赋值给冰柜
                let row_=null;
                for(let i=0;i<this.data[this.dataField].length;i++){
                    let item=this.data[this.dataField][i];
                    let szi_ex2=Number(item.szi_ex2);
                    let szi_ex1=item.szi_ex1;
                    let szi_ex19=item.szi_ex19;
                    
                    if((","+szi_ex19+",").indexOf(","+szi_ex1_+",")!=-1){
                        row_=item;
                    }
                }

                if(row_){
                    let szi_ex4_=Number(row_.szi_ex4);
                    let szi_ex5_=row_.szi_ex5;
                    let szi_ex2=Number(row.szi_ex2);
                    row.szi_ex4=szi_ex4_;
                    row.szi_ex5=szi_ex2*szi_ex4_;
                    //这里其实就是修改刚刚添加的服务项目的数量和金额
                    this.$set(this.data[this.dataField], this.data[this.dataField].length-1 , row); 
                }
                //添加相关联的服务项目
                if(data.name){
                    let names=data.name.split(",");
                    for(let i=0;i<names.length;i++){
                        let n=names[i];
                        //该方法后面还会在调用本方法
                        this.addItemDetail(n,"",hour,day);
                        
                    }
                }
                //找到相关联项目，这个主要是修改相关联项目的数量（根据天数和小时，比如礼厅相关联的项目，冰柜）
                if(data.name2){
                    let names2=data.name2.split(",");
                    
                    for(let h=0;h<names2.length;h++){
                        let n=names2[h];
                        let isSave=false;
                        for(let i=0;i<this.data[this.dataField].length;i++){
                            let item=this.data[this.dataField][i];
                            let szi_ex2=Number(item.szi_ex2);
                            let szi_ex1=item.szi_ex1;
                            let szi_ex4=Number(item.szi_ex4);
                            let szi_ex3=item.szi_ex3;
                            let szi_ex5=Number(item.szi_ex5);
                            let szi_ex5_=0;
                            if(szi_ex1==n){
                                if(szi_ex3.indexOf("时")!=-1){
                                    if(hour){
                                        szi_ex5_=hour*szi_ex2;
                                        item.szi_ex4=hour;
                                        isSave=true;
                                    }
                                    
                                    
                                }else{
                                    if(day){
                                        szi_ex5_=day*szi_ex2;
                                        item.szi_ex4=day;
                                        isSave=true;
                                    }
                                    
                                }
                                if(szi_ex5!=szi_ex5_&&isSave){
                                    item.szi_ex5=szi_ex5_;
                                    this.$set(this.data[this.dataField], i , item); 
                                        
                                }
                            }
                        }
                    }

                    
                }

               // this.setJm();
                //this.changeAmt();
            })
        },
        //根据名字来添加
        addItemDetail(name,itemType,hour,day){
            console.log("name===="+name+"=="+itemType+"=="+hour+"+"+day);
            console.log(this.sfItemData);
             let row=null;
             for(let i=0;i<this.sfItemData.length;i++){
                let szi_ex1=this.sfItemData[i].szi_ex1;
                let szi_ex7=this.sfItemData[i].szi_ex7;
                if(itemType){
                    if(szi_ex1==name&&itemType==szi_ex7){
                        row=this.sfItemData[i];
                    }
                }else{
                    if(szi_ex1==name){
                        row=this.sfItemData[i];
                    }
                }
                
            }
            let isOk=true;
           
             if(row!=null){
                for(let i=0;i<this.data[this.dataField].length;i++){
                    let szi_ex1=this.data[this.dataField][i].szi_ex1;
                    let szi_ex7=this.data[this.dataField][i].szi_ex7;
                    if(itemType){
                        if(szi_ex1==row.szi_ex1&&itemType==szi_ex7){
                            isOk=false;
                        }
                    }else{
                        if(szi_ex1==row.szi_ex1){
                            isOk=false;
                        }
                    }
                    
                }
            
            }
            console.log(row);
            console.log("isOk================="+isOk)
            if(row!=null&&isOk){
                if(itemType){
                    let index=-1;
                    for(let i=0;i<this.data[this.dataField].length;i++){
                        let szi_ex7=this.data[this.dataField][i].szi_ex7;
                        if(szi_ex7==itemType){
                            index=i;
                        }
                    
                    }
                    if(index!=-1){
                        this.$delete(this.data[this.dataField],index)
                        //this.data[this.dataField].splice(index,1);
                       
                    }
                }
                if(!row.szi_ex13)
                    row.szi_ex13=this.params;

                let szi_ex3=row.szi_ex3;
                let num=1;
                let szi_ex2=Number(row.szi_ex2);
               
                if(hour&&szi_ex3.indexOf("时")!=-1){
                    num=hour;
                    let szi_ex5=num*szi_ex2;
                    row.szi_ex5=szi_ex5;
                    row.szi_ex4=num;
                }else if(day&&szi_ex3.indexOf("天")!=-1){
                    num=day;
                    let szi_ex5=num*szi_ex2;
                    row.szi_ex5=szi_ex5;
                    row.szi_ex4=num;
                }
                console.log("hour====================="+hour+"===="+day+"=="+szi_ex3);
                console.log(row)

                this.$set(this.data[this.dataField], this.data[this.dataField].length , row); 
                this.addRelItem(row,hour,day)


            }
        },
        changeInput(data){
            console.log("changeInput=====================================")
            
           
          //  this.$emit("input",data);
            let datas=JSON.parse(data);
           
            if(datas.type!="add")
                this.setJm();
            this.changeAmt();
        },
        changeAmt(){
            let amt=0;
            let amt_total=0;
            let amt_jm=0;
            let amt_yh=0;
            this.change=false;
            for(let i=0;i<this.data[this.dataField].length;i++){
                let item=this.data[this.dataField][i];
                let szi_ex2=Number(item.szi_ex2);
                let szi_ex4=Number(item.szi_ex4);
                let szi_ex12=item.szi_ex12;
                let szi_ex5=szi_ex2*szi_ex4;
                let szi_ex5_=item.szi_ex5;
                if(szi_ex5!=szi_ex5_){//如果总金额不一样了，才重新赋值
                     item.szi_ex5=szi_ex5;
                     this.$set(this.data[this.dataField], i , item); 
                     this.change=true;
                }
               
                amt+=szi_ex5;
                if(szi_ex5<0)
                    amt_jm+=szi_ex5;
                else
                    amt_total+=szi_ex5;

                if(szi_ex12){
                    szi_ex12=Number(szi_ex12);
                    amt-=szi_ex12;
                    amt_yh+=szi_ex12;
                }
            }
            
            this.yh_totals=amt_yh;
            this.amt_totals=amt_total;
            this.jm_totals=-amt_jm;
            this.sh_totals=amt;
        },
        getDaysBetween(dateString1,dateString2){
            var  startDate = Date.parse(dateString1);
            var  endDate = Date.parse(dateString2);
            var days=(endDate - startDate)/(1*24*60*60*1000);
            // alert(days);
            return  days;
        },
        getDaysBetweenHour(dateString1,dateString2){
            var  startDate = Date.parse(dateString1);
            var  endDate = Date.parse(dateString2);
            var days=(endDate - startDate)/(1*60*60*1000);
            // alert(days);
            return  days;
        },
        
        //管理费
        loadGlf(){
            console.log("isgm================="+this.isgm)
            if(this.isgm=="Y"){
                this.$post("business","/api/common/readCommonSet",{id:"管理费设置"}).then(data=>{
                    let set1=data.set1;
                    let set2=data.set2;
                    if(set1=="初次购买需要收取"){
                        let c_ex4=this.data["gmInfo"].c_ex4;

                        if(c_ex4){
                            let row=null;
                            let isAdd=true;
                            for(let i=0;i<this.sfItemData.length;i++){
                                let szi_ex7=this.sfItemData[i].szi_ex7;
                                if(szi_ex7=="管理费"){
                                    row=this.sfItemData[i];
                                }
                            }
                            for(let i=0;i<this.data["item"].length;i++){
                                let szi_ex7=this.data["item"][i].szi_ex7;
                                if(szi_ex7=="管理费"){
                                    isAdd=false;
                                }
                            }
                            if(row&&isAdd){
                                let set2_=Number(set2);
                                row.szi_ex2=c_ex4;
                                row.szi_ex4=set2;
                                row.szi_ex5=set2_*Number(c_ex4);
                                this.$set(this.data["item"],this.data["item"].length,row);
                            }
                        }
                        this.isSetGlf="Y"
                    }
                })
                
            }
        },
            //startDateStr(2017-02-22) endDateStr(2018-02-21)
        getDateYearSub(startDateStr, endDateStr) {
            var day = 24 * 60 * 60 *1000; 

            var sDate = new Date(Date.parse(startDateStr.replace(/-/g, "/")));
            var eDate = new Date(Date.parse(endDateStr.replace(/-/g, "/")));

            //得到前一天(算头不算尾)
            sDate = new Date(sDate.getTime() - day);

            //获得各自的年、月、日
            var sY  = sDate.getFullYear();     
            var sM  = sDate.getMonth()+1;
            var sD  = sDate.getDate();
            var eY  = eDate.getFullYear();
            var eM  = eDate.getMonth()+1;
            var eD  = eDate.getDate();
            console.log(eY+"="+sY+"="+sM+"="+eM)
            if(eY > sY && sM == eM) {
                return eY - sY;
            } else {
                alert("两个日期之间并非整年，请重新选择");
                return 0;
            }
        }
        
    },
    watch:{
        value:{
            handler:function(newVal){
                this.sz_ex42=newVal;
                this.$set(this.data["szInfo"],"sz_ex42",newVal)
                this.isJm=true;
                this.setJm();
                this.changeAmt();
                this.isJm=false;
            }
        },
         /*data:{
            handler: function (newVal) {
                let datas=this.$refs.tableEditss.getData();
                console.log("变更了--------------------------------------------------------")
                console.log(this.data);
                if(this.isgm=="Y"){
                    try{
                        let gm_dat3=this.data["gmInfo"].gm_dat3;
                        let gm_dat4=this.data["gmInfo"].gm_dat4;
                        let c_ex57=this.data["gmInfo"].c_ex57;
                        let c_ex4=this.data["gmInfo"].c_ex4;
                        if((c_ex57==""||c_ex57=="N")&&(gm_dat3!=this.gm_dat3||gm_dat4!=this.gm_dat4)&&gm_dat3&&gm_dat4){
                             let years=this.getDateYearSub(gm_dat3,gm_dat4);
                             let index=-1;
                             for(let i=0;i<this.data["item"].length;i++){
                                let szi_ex7=this.data["item"][i].szi_ex7;
                                if(szi_ex7=="管理费"){
                                    index=i;
                                }
                            }
                            if(index>=0&&years){
                                let item=this.data["item"][index];
                                let szi_ex2=Number(this.data["item"][index].szi_ex2);
                                this.data["item"][index].szi_ex4=years;
                                this.data["item"][index].szi_ex5=Number(years)*szi_ex2;
                                //this.$set(this.data["item"],index,)
                            }
                            this.gm_dat3=gm_dat3;
                            this.gm_dat4=gm_dat4;
                        }
                        if((c_ex57==""||c_ex57=="N")&&c_ex4!=this.c_ex4){
                            let index=-1;
                             for(let i=0;i<this.data["item"].length;i++){
                                let szi_ex7=this.data["item"][i].szi_ex7;
                                if(szi_ex7=="管理费"){
                                    index=i;
                                }
                            }
                            if(index>=0&&c_ex4){
                                let item=this.data["item"][index];
                                let szi_ex4=Number(this.data["item"][index].szi_ex4);
                                this.data["item"][index].szi_ex2=c_ex4;
                                this.data["item"][index].szi_ex5=Number(c_ex4)*szi_ex4;
                                //this.$set(this.data["item"],index,)
                            }
                            this.c_ex4=c_ex4;
                        }
                    }catch(e){}
                }
                
                
            },      
            deep: true    //深度监听
        },*/
        item:{
            deep:true,
            handler:function(newV,oldV){
                console.log("this.change=================================="+this.change+"="+this.isJm)
                this.$refs.tableeditgroup.initData();
                if(!this.change&&!this.isJm){
                    this.setJm();
                    this.changeAmt();
                }else{
                    this.change=false;
                }
            }
        }
    },
     computed:{
       item(){
         return this.data.item;
       }
     },
}
</script>
<style scoped>
.funeral_item_table{
    height:100%;
    display:flex;
    flex-direction: column;
    overflow:hidden;
    position:relative;
}
.tableEdit{
    flex:1;
}
.amt_total{
    height:40px;
    border:1px solid #ddd;
    line-height:20px;
    box-sizing: border-box;
    -moz-box-sizing: border-box;
    -webkit-box-sizing: border-box;
    text-align: right;
    background:#ddd;
    -moz-box-shadow: 2px 2px 10px #909090;
   -webkit-box-shadow: 2px 2px 10px #909090;
   box-shadow:2px 2px 10px #909090;

}
.amt_total_item{
    
    padding:10px;
}
.funeral_item_table >>> .el-drawer{
    width:65% !important;
}
</style>
<style >

.el-drawer__header{
    margin-bottom:0 !important;
    padding:10px 10px 0 !important;
}
.el-card__header{
    padding:5px 5px !important;
}
.el-card__body{
    padding-top:0 !important;
    padding-left:0 !important;
    padding-right:0 !important;
}
</style>
<style >

</style>